'use strict';

/**
 * @ngdoc function
 * @name angularYoBranchApp.controller:MainCtrl
 * @description
 * # MainCtrl
 * Controller of the angularYoBranchApp
 */

var angulars =  angular.module('angularYoBranchApp')

angulars.controller('MainCtrl', function ($interval) {
    this.awesomeThings = [
      'HTML5 Boilerplate',
      'AngularJS',
      'Karma'
    ];
    var that = this
    var timer = $interval(function(){
        that.time = new Date().getTime()
    },1000)
  });
angulars.controller('AboutCtrl', function ($scope) {
    $scope.menu = [
      'HTML5 Boilerplate',
      'AngularJS',
      'Karma'
    ];
  });

angulars.directive("hello", function() {
  return {
      //restrict : "C", // class才能用  
      //restrict : "M", replace : true,//注释 
      template : "<h1>自定义标签!</h1>"
  };
});


angulars.service('hexafy',function(){
  this.fun = function(x){
      return x.toString(16)
  }
})
angulars.config(function($provide){
  $provide.provider('mathmax',function(){
    this.$get=function(){
        // var factory = {};  
         
        //  factory.multiply = function(a, b) {
        //     return a * b; 
        //  }
        //  return factory;

      return {
        factory:function(arr){
                  arr.sort(function(a,b){
                      return a-b
                  })
                  return arr.pop()
                }
        
      }
    }
  })
})

angulars.controller('htt',function($scope,$http,hexafy,mathmax){
    var that = this
    $http.get('./json/$http.json').then(function(response){
        that.data = response.data.data
    })
    console.log(mathmax)
    this.val = hexafy.fun(255)
    // this.max = mathmax.multiply(...[20,20])
    this.max = mathmax.factory([1,20,111,22,365,1111])
})


